package labox.innovation.gameserver.network.serverpackets;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import labox.innovation.config.Config;
import labox.innovation.gameserver.GmListTable;
import labox.innovation.gameserver.ThreadPoolManager;
import labox.innovation.gameserver.network.L2GameClient;

/**
 * ��������������У��Э��
 * 
 * @author squll
 */
public class GameGuardQuery extends L2GameServerPacket {

	private static final Logger _log = LoggerFactory.getLogger(GameGuardQuery.class.getName());

	private static final String _S__16_GAMEGUARDQUERY = "[S] 16 GameGuardQuery";

	public GameGuardQuery() {
	}

	@Override
	public void writeImpl() {
		writeByte(PTL_GAMEGUARDQUERY);
	}

	@Override
	public void runImpl() {
		getClient().setGameGuardOk(false);
		ThreadPoolManager.getInstance().schedule(new Runnable() {
			public void run() {
				L2GameClient client = getClient();
				if (client != null && !client.isAuthedGG()) {
					GmListTable.broadcastMessageToGMs("Client " + client + " failed to reply GameGuard query and is being kicked!");
					_log.warn("GameGuardHack:Client " + client + " failed to reply GameGuard query and is being kicked!", Config.SERVER_ID);
					client.closeNow();
				}
			}

		}, 15 * 1000);
	}

	@Override
	public String getType() {
		return _S__16_GAMEGUARDQUERY;
	}
}
